module.exports = {
    render: function () {
        var __table = new icu.table({
            whereOptions: [
                {
                    key: 'str',
                    type: 'input',
                    labelText: '测试：',
                    labelWidth: 60,
                }, {
                    key: 'str2',
                    type: 'select',
                    data: 'OptionSide:Gender',
                    labelText: '测试：',
                    labelWidth: 60,
                }, {
                    key: 'str3',
                    type: 'radio',
                    data: 'OptionSide:Gender',

                }
            ],
            rightButtons: [
                {
                    class: 'Test',
                    name: '导出CSV',
                    event: 'exportCSV',
                    icon: 'squareAdd'
                }, {
                    class: 'Test',
                    name: '导出XLS',
                    event: 'exportXLS'
                }, {
                    class: 'Test',
                    name: '打印',
                    event: 'print'
                }
            ],
            whereButtons: [{
                class: 'Test',
                name: '搜索',
                event: 'search',
                icon: 'squareAdd'
            }, {
                class: 'Test',
                name: '重置',
                event: 'reset'
            }, {
                class: 'Test',
                name: '刷新',
                event: 'refresh'
            }, {
                class: 'Test',
                name: '筛选',
                event: 'screen'
            }],
            tableOptions: {
                minWidth: 40,
                titleAlign: 'left',
                followPage: true,
            },
            cols: [
                {
                    key: "index",
                    type: 'index',
                    width: '90px',
                    name: '序号',
                    titleAlign: 'center',
                    textAlign: 'center',
                },
                {
                    type: 'checkBox',
                    width: '40px',
                }, {
                    type: 'radio',
                    width: '40px',
                }, {
                    key: 'S',
                    type: 'OptionSide:Gender:value:label',
                    name: '字符串',
                    width: '30px',
                    sort: true,
                    format: function (data, value, ele) {
                        ele.click(() => {
                            console.log(data);
                        });
                    },
                }, {
                    key: 'B',
                    type: 'buttons',
                    name: 'B',
                    buttons: [function (unit, row, data) {
                        var button = '';
                        if (data.B == 'AAAAA') {
                            var button = $('<div class="layui-btn layui-btn-sm layui-btn-ys Test">按钮1</div>');
                            button.click((e) => {
                                e.stopPropagation();
                                e.preventDefault();
                                icu.alert.normal({
                                    text: JSON.stringify(data),
                                });
                            });
                        };
                        return button;
                    }],
                }, {
                    key: 'C',
                    sort: true,
                    type: 'string',
                    name: 'C',
                }, {
                    key: 'D',
                    type: 'string',
                    name: 'D',
                }, {
                    key: 'E',
                    type: 'string',
                    name: 'E',
                }, {
                    key: 'F',
                    type: 'string',
                    name: 'F',
                }
            ],
            getEvent: function (data, setData) {
                console.log(data);

                setData({
                    count: 100,
                    data: [
                        { S: '3333333333333333333333333333', A: 'C', B: 'AAAAA', C: '张一', D: 'D', E: 'E', F: 'F' },
                        { S: '5', A: 'E', B: 'E', C: '李四', D: 'D', E: 'E', F: 'F' },
                        { S: '2', A: 'B', B: 'b', C: '王,五', D: 'D', E: 'E', F: 'F' },
                        { S: '4', A: 'D', B: 'd', C: '赵六', D: 'D', E: 'E', F: 'F' },
                        { S: '10', A: 'J', B: 'j', C: '张"",,,""二', D: 'D', E: 'E', F: 'F' },
                        { S: '8', A: 'H', B: 'h', C: '王,五', D: 'D', E: 'E', F: 'F' },
                        { S: '7', A: 'G', B: 'G', C: '赵"六', D: 'D', E: 'E', F: 'F' },
                        { S: '1', A: 'A', B: 'A', C: '"张三"', D: 'D', E: 'E', F: 'F' },
                        { S: '6', A: 'F', B: 'f', C: '李四', D: 'D', E: 'E', F: 'F' },
                        { S: '9', A: 'I', B: 'I', C: '王五', D: 'D', E: 'E', F: 'F' },
                    ]
                });

            },
        });
        this.$el.find('#tableText').append(__table.html);
        __table.init();
        __table.on('rowClick', function (data, table, row) {
            for (let i = 0; i < table.objs.body.childrens.length; i++) {
                const element = table.objs.body.childrens[i];
                element.html.css({
                    background: '#fff',
                })
            };
            row.radioSelect();
            row.html.css({
                background: '#f0f0f0',
            });
        });
        __table.on('rowDblclick', function (data, table, row) {
            icu.alert.normal({
                text: JSON.stringify(data),
            })
        });
        this.$el.find('#getCheckValue').click(() => {
            var data = __table.getCheckBoxValue();
            icu.alert.normal({
                text: JSON.stringify(data),
            });
        });
        this.$el.find('#getRadioValue').click(() => {
            var data = __table.getRadioValue();
            icu.alert.normal({
                text: JSON.stringify(data),
            })
        });
    },
};